package com.heima.user.config;

import com.heima.model.user.pojos.ApUser;
import com.heima.user.mapper.ApUserMapper;
import com.heima.user.service.ApUserImportAndExportService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;
import java.util.List;
import java.util.concurrent.TimeUnit;

@Component
public class redisInit implements ApplicationRunner {
    @Autowired
    ApUserImportAndExportService importService;

    @Autowired
    StringRedisTemplate redisTemplate;

    @Override
    public void run(ApplicationArguments args) throws Exception {
        List<ApUser> list = importService.list();
        String phone = "";
        for (ApUser apUser : list) {
            phone += apUser.getPhone()+"/";
        }
        redisTemplate.opsForValue().set("phone",phone);
    }
}
